package tower.ai.base.chat.config;

import org.springframework.ai.moonshot.MoonshotChatModel;
import org.springframework.ai.moonshot.MoonshotChatOptions;
import org.springframework.ai.moonshot.api.MoonshotApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MoonshotConfig {

    @Value("${spring.ai.moonshot.api-key}")
    private String apiKey;

    @Value("${spring.ai.moonshot.chat.model}")
    private String model;

    @Value("${spring.ai.moonshot.chat.temperature}")
    private float temperature = 0.7f;

    @Bean
    public MoonshotApi moonshotApi() {
        return new MoonshotApi(apiKey);
    }

    @Bean
    public MoonshotChatModel moonshotChatModel(MoonshotApi moonshotApi) {
        return new MoonshotChatModel(moonshotApi,
                MoonshotChatOptions.builder()
                        .withModel(model)
                        .withTemperature(temperature)
                        .withMaxTokens(200)
                        .build());
    }

}
